/*
 * ODO: Real-Time In-Memory ORM/DBMS Grid software
 * Copyright (c) 2008, Michael Oksenenko
 * All rights reserved.
 */
//----------------------------------------------------------------------------
#include "OsConfig.hpp"
#if ODO_OS_VISTA == ODO_CHOSEN_OS
//----------------------------------------------------------------------------
#include "SyslogInstallerVista.hpp"

#include "OsComponentFactory.hpp"
#include <iostream>

using namespace odo;

void SyslogInstallerVista::install(
	const wchar_t* aSyslogLib, const wchar_t* aSyslogName
) {
	std::wcout << "Syslog installer begin..." << std::endl;

	const wchar_t* SYSLOG_PATH = L"SYSTEM\\CurrentControlSet\\Services\\Eventlog\\Application\\";
	const wchar_t* VALUE_NAME = L"EventMessageFile";

	std::wstring value = OsComponentFactory::getProcess()->getCurrentProcessPath();
	value.append(aSyslogLib);
	value.append(L".dll");

	std::wstring key(SYSLOG_PATH);
	key.append(aSyslogName);

	std::wcout << "Syslog installer data:"
		<< std::endl << L"  syslog lib       : " << aSyslogLib
		<< std::endl << L"  syslog name      : " << aSyslogName
		<< std::endl << L"  syslog path      : " << SYSLOG_PATH
		<< std::endl << L"  syslog key       : " << key.c_str()
		<< std::endl << L"  syslog value_name: " << VALUE_NAME
		<< std::endl << L"  syslog value     : " << value.c_str()
		<< std::endl;

	std::auto_ptr<RegeditIF> regedit = OsComponentFactory::getRegedit();
	regedit->openKey(key.c_str());
	regedit->setValue(VALUE_NAME, value.c_str());
	regedit->closeKey();

	std::auto_ptr<SyslogIF> syslog = OsComponentFactory::getSyslog();
	syslog->logInfo(L"Syslog installer test INFO event.");
	syslog->logWarn(L"Syslog installer test WARN event.");
	syslog->logFail(L"Syslog installer test FAIL event.");

	std::wcout << "Syslog installer done." << std::endl;
}

SyslogInstallerVista::~SyslogInstallerVista() {
	// void
}

SyslogInstallerVista::SyslogInstallerVista() {
	// void
}
//----------------------------------------------------------------------------
#endif /* ODO_OS_VISTA */
//----------------------------------------------------------------------------
